<template>
  <div>
    <div class="myRat  pd20px"  >
      <textarea name="" id="" :placeholder="myRatData.placeholder" v-model="myRat"></textarea>
      <div class="publish f-bian">
        <div ><div v-if="myRatData.starShow" class="flex">评分：<star :score="score.toString()" @do_getScore="do_getScore($event)" big="bigger"></star></div></div>
        <button class="f-zhong" @click="do_rat()">发表</button>
      </div>
    </div>
  </div>
</template>

<script>
  import star from '../common/cm_star'
    export default {
        name: "detail-ratTexarea",
      inject:['reload'],
      components:{
        star
      },
      data(){
          return{
            score:'0',
            myRat:''

          }
      },
      props:{
        myRatData:Object
      },
      methods:{
        do_getScore(index){
          this.score=index+1
        },
        do_rat(){

          let me = this;
          me.$ZcPublic.zcServer.Post({
            IsNeedLogin: 'false',
            Paras: {
              Name: 'Vue_resultLib',
              action: "doEvaluat_ResultShow",
              Data: {

                  ResultShowSN:me.myRatData.SN,
                  OpPhoneNumber:localStorage.telephone,
                  EvaluatValue:me.score,
                  Remark:me.myRat

              }
            },
            Callback: me.cb_do_rat,
            Scope: me,
          });
        },
        cb_do_rat(resJson,scope){
          console.log('评价返回',resJson)
          if(resJson.success){
            let me=this
            me.$toast({
              icon:'ok',
              msg:'评价成功！'
            })
            setTimeout(()=>{
              me.reload()
            },1600)
          }else {
            this.$confirm({
              type:'错误',
              msg:resJson.msg,
              btn:{
                ok:'ok'
              }
            })
          }
        }
      }
    }
</script>

<style scoped>
  .pd20px{
    padding: 20px;
  }
  .myRat textarea{
    width: 100%;
    min-height: 75px;
    line-height: 25px;
    border: none;
    background-color: #E6E6E6;
  }
  .publish{
    height: 40px;
    line-height: 40px;
    align-items: center;
  }
  .publish button{
    height: 36px;
    line-height: 36px;
    padding: 0 25px;
    border-radius: 2px;
    cursor: pointer;
    background-color: #418DFD;
    color: white;
    border: none;
  }
</style>
